//序号函数
function showSortNum(cellvalue, options, row) {
	return options.rowId;
}

function hrefUrl(cellvalue, options, row, url) {
	// row.a row.b,
	// options.rowId,options.gid,options.pos,options.colModel
	return "<a href='" + url + "'>" + cellvalue + "</a>" + row.b;
}

function showLink(cellvalue, options, row) {
	// row.a row.b,
	// options.rowId,options.gid,options.pos,options.colModel
	return "<a href='#'>" + cellvalue + "</a>" + row.b;
}

// 公共调用方法
function Merger(gridName, CellName) {
	// 得到显示到界面的id集合
	var mya = $("#" + gridName + "").getDataIDs();
	// 当前显示多少条
	var length = mya.length;
	for ( var i = 0; i < length; i++) {
		// 从上到下获取一条信息
		var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
		// 定义合并行数
		var rowSpanTaxCount = 1;
		for (j = i + 1; j <= length; j++) {
			// 和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
			var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
			if (before[CellName] == end[CellName]) {
				rowSpanTaxCount++;
				$("#" + gridName + "").setCell(mya[j], CellName, '', {
					display : 'none'
				});
			} else {
				rowSpanTaxCount = 1;
				break;
			}
			$("#" + CellName + "" + mya[i] + "").attr("rowspan",
					rowSpanTaxCount);
		}
	}
}

// 样式
function replaceCss() {
	$("#load_grid-table").hide();
	var table = this;
	var t1 = setTimeout(function() {
		var replacement = {
					'ui-icon-seek-first' : 'glyphicon glyphicon-fast-backward',
					'ui-icon-seek-prev' : 'glyphicon glyphicon-backward',
					'ui-icon-seek-next' : 'glyphicon glyphicon-forward',
					'ui-icon-seek-end' : 'glyphicon glyphicon-fast-forward'
		};
		$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(
			function() {
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if ($class in replacement)
					icon.attr('class', replacement[$class]);
			});
	}, 100);
			
	/**
	 var rowNum = $(grid_selector).jqGrid('getGridParam','records');
	if (rowNum>0){
		 $("#norecords").hide();
    } else { 
		$(grid_selector).parent().append("</pre><div id='norecords'>没有查询记录！</div><pre>");
        $("#norecords").show();
    }
	 */
	// 隐藏纵向滚动条
	$("#grid-table").closest(".ui-jqgrid-bdiv").css({ 'overflow-y' : 'hidden' });
}